package org.robot.power;

import java.util.Collection;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;

import org.robot.component.Attachment;

/**
 * 调度器
 * @author pdz
 * @date 2018年10月11日
 */
public class Schedule {

    private BlockingQueue<Attachment> queue = new LinkedBlockingQueue<>();
    
    public void add(Attachment attachment) {
        queue.offer(attachment);
    }

    public void addAll(Collection<? extends Attachment> c) {
        queue.addAll(c);
    }
    
    public boolean has() {
        return !queue.isEmpty();
    }

    public Attachment take() {
        return queue.poll();
    }
    
    public boolean remove(Attachment attachment) {
    	return queue.remove(attachment);
    }


}
